﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Common;

public partial class _root_desktop_sub : PageBase
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Response.Expires = -1;
        PageBegin();

        switch (RequestBase.GetQueryString("typecode"))
        {
            case "1":
                if (Validate("received doc", 1))
                    txtRegisterRights.Value = "1";
                else
                    txtRegisterRights.Value = "0";
                break;
            case "2":
                if (Validate("dispatch doc", 1))
                    txtRegisterRights.Value = "1";
                else
                    txtRegisterRights.Value = "0";
                break;
        }

        switch (RequestBase.GetFormString("otype"))
        {
            case "getreminderdata":
                GetReminderData();
                break;
        }
    }

    #region 获取提醒数据
    void GetReminderData()
    {
        /// 1 公文管理
        string groupid = RequestBase.GetFormString("groupid");
        /// 1 收文, 2 发文
        string typecode = RequestBase.GetFormString("typecode");

        string res = "";
        string SQL = "";
        try
        {
            switch (groupid)
            {
                case "1":
                    /// 未处理的登记表
                    SQL = " AND DeletionStateCode = 0 AND DocumentTypeCode = " + typecode + " AND StatusCode IN (0, 1) AND CreateBy = '" + this.SystemUserId + "'";
                    object _obj = BLL.CommonBLL.ExecuteScalar("vw_DocumentQueueBase", "COUNT(1)", SQL);
                    if (_obj != null)
                    {
                        res += _obj.ToString() + "|";
                    }
                    
                    /// 收文单
                    SQL = " AND DeletionStateCode = 0 AND DocumentTypeCode = " + typecode + " AND ProcessingTypeCode = 1";
                    SQL += " AND ((CreateBy = '" + this.SystemUserId + "' AND StatusCode IN (2, 3))";
                    SQL += " OR DocumentQueueId IN (SELECT DocumentQueueId FROM TaskBase WHERE OwnerId = '" + this.SystemUserId + "' AND OwnerTypeCode = 2 AND StatusCode = 0))";
                    _obj = BLL.CommonBLL.ExecuteScalar("vw_DocumentQueueBase", "COUNT(1)", SQL);
                    if (_obj != null)
                    {
                        res += _obj.ToString() + "|";
                    }
                    
                    /// 传阅件
                    SQL = " AND DeletionStateCode = 0 AND DocumentTypeCode = " + typecode + " AND ProcessingTypeCode = 2";
                    SQL += " AND ((CreateBy = '" + this.SystemUserId + "' AND StatusCode IN (2, 3))";
                    SQL += " OR DocumentQueueId IN (SELECT DocumentQueueId FROM TaskBase WHERE OwnerId = '" + this.SystemUserId + "' AND OwnerTypeCode = 2 AND StatusCode = 0))";
                    _obj = BLL.CommonBLL.ExecuteScalar("vw_DocumentQueueBase", "COUNT(1)", SQL);
                    if (_obj != null)
                    {
                        res += _obj.ToString();
                    }
                    break;
            }
        }
        catch (Exception err)
        {
            res = "faild";
        }

        BLL.AjaxHelper.ResponseWrite(res);
    }
    #endregion
}
